<!DOCTYPE html>
<html>
#{include file="header.html"}#
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5><i class="fa fa-home"></i>采购合同详细</h5>
            <div class="ibox-tools">
                <button type="button" class="btn btn-xs btn-primary btn-back-reply"><i class="fa fa-reply"></i> 返回 </button>
            </div>
        </div>
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-10">
                    <div class="m-b-md">
                        <h3>#{$one.title}#</h3>
                    </div>
                </div>
                <div class="col-sm-2">#{$one.status_arr.status_name_html}#</div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="ibox-content ">
                        <p><strong>合同编号：</strong>#{$one.contract_no}#</p>
                        <p><strong>合同金额：</strong>#{$one.money}#</p>
                        <p><strong>去零金额：</strong>#{$one.zero_money}#</p>
                        <p><strong>付款金额：</strong>#{$one.pay_money}#</p>
                        <p><strong>欠款金额：</strong>#{$one.owe_money}#</p>
                        <p><strong>开始时间：</strong>#{$one.start_date}#</p>
                        <p><strong>结束时间：</strong>#{$one.end_date}#</p>
                        <p><strong>采购备注：</strong>#{$one.remarks}#</p>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="ibox-content ">
                        <p><strong>创建时间：</strong>#{$one.create_time}#</p>
                        <p><strong>供应商名称：</strong>#{$one.supplier.name}#</p>
                        <p><strong>联系代表：</strong>#{$one.linkman.name}#</p>
                        <p><strong>我方代表：</strong>#{$one.our_user_arr.name}#</p>
                    </div>
                </div>
            </div>
            <div class="row m-t-sm">
                <div class="col-sm-12">
                    <div class="panel blank-panel">
                        <div class="panel-heading">
                            <div class="panel-options">
                                <ul class="nav nav-tabs">
                                    <li class="active"><a href="?#tab-1" data-toggle="tab">采购明细</a></li>
                                    <li class=""><a href="?#tab-2" data-toggle="tab">付款记录</a></li>
                                    <li class=""><a href="?#tab-3" data-toggle="tab">收票记录</a></li>
                                    <li class=""><a href="?#tab-4" data-toggle="tab">日志记录</a></li>
                                </ul>
                            </div>
                        </div>
                        <div class="panel-body">
                            <div class="tab-content">
                                <div class="tab-pane active" id="tab-1">
                                    <table class="table table-hover sorttable 07fly-table">
                                        <thead>
                                        <tr>
                                            <th width="100">商品名称/商品规格</th>
                                            <th width="50"><span>进货价格</span></th>
                                            <th width="50"><span>数量</span></th>
                                            <th width="50"><span>小计</span></th>
                                            <th width="50"><span>备注</span></th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="tab-pane" id="tab-2">
                                    <table class="table table-hover sorttable 07fly-table">
                                        <thead>
                                        <tr>
                                            <th width="100"><span>供应商</span></th>
                                            <th width="100"><span>采购合同</span></th>
                                            <th width="80"><span>付款时间</span></th>
                                            <th width="60"><span>期次</span></th>
                                            <th width="80"><span>金额</span></th>
                                            <th width="80"><span>去零</span></th>
                                            <th width="80"><span>创建人</span></th>
                                            <th width="100"><span>创建时间</span></th>
                                            <th width="100"><span>备注</span></th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="tab-pane" id="tab-3">
                                    <table class="table table-hover sorttable 07fly-table">
                                        <thead>
                                        <tr>
                                            <th width="200" orderField="by_supplier" class="sort-filed"><span>供应商</span></th>
                                            <th width="150"><span>合同单号</span></th>
                                            <th width="200"><span>发票金额/编号</span></th>
                                            <th width="100" orderField="by_recedate" class="sort-filed"><span>收票时间</span></th>
                                            <th width="60"><span>期次</span></th>
                                            <th width="80"><span>创建人</span></th>
                                            <th><span>备注</span></th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        </tbody>
                                    </table>

                                </div>
                                <div class="tab-pane" id="tab-4"> 功能开发中。。444。</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
</html>

<script id="tab-1-Tpl" type="text/html">
    <% for(var i=0;i
    <list.length;i++) { %>
    <tr>
        <td>
            <input type="hidden" name="sku_id[]" value="<%=list[i]['sku_id']%>">
            <input type="hidden" name="sku_name[]" value="<%=list[i]['sku_id']%>">
            <input type="hidden" name="goods_id[]" value="<%=list[i]['goods_id']%>">
            <input type="hidden" name="goods_name[]" value="<%=list[i]['goods_name']%>">
            <%=list[i]['goods_name']%>/<%=list[i]['sku_name']%>
        </td>
        <td><%=list[i]['cost_price']%></td>
        <td><%=list[i]['num']%></td>
        <td><%=list[i]['goods_money']%></td>
        <td><%=list[i]['remarks']%></td>
    </tr>
    <% } %>
    <tr>
        <td lass="text-center"><strong>合计：</strong></td>
        <td></td>
        <td><span class="text-danger"><%=totalCount['total_num']%></span></td>
        <td><span class="text-danger">￥<%=totalCount['total_goods_money']%></td>
        <td></td>
    </tr>
</script>
<script id="tab-2-Tpl" type="text/html">
    <% for(var i=0;i
    <list.length;i++) { %>
    <tr>
        <td><%=list[i]['supplier']['name']%></td>
        <td><%=list[i]['contract']['title']%></td>
        <td><%=list[i]['pay_date']%></td>
        <td><%=list[i]['stages']%></td>
        <td><%=list[i]['money']%></td>
        <td><%=list[i]['zero_money']%></td>
        <td><%=list[i]['create_user_arr']['name']%></td>
        <td><%=list[i]['create_time']%></td>
        <td><%:=list[i]['intro']%></td>
    </tr>
    <% } %>
    <tr>
        <td colspan="11" align="left">
            金额合计：<span class="text-danger">&yen;<%=countMoney['total_money']%></span>
        </td>
    </tr>
</script>
<script id="tab-3-Tpl" type="text/html">
    <% for(var i=0;i<list.length;i++) { %>
    <tr>
        <td><%=list[i]['supplier']['name']%></td>
        <td><%=list[i]['contract']['title']%></td>
        <td>
            <p>内容：<%=list[i]['name']%></p>
            <p>编号：<%=list[i]['invoice_no']%></p>
            <p>金额：<%=list[i]['money']%></p>
        </td>
        <td><%=list[i]['rece_date']%></td>
        <td><%=list[i]['stages']%></td>
        <td><%=list[i]['create_user_arr']['name']%></td>
        <td><%:=list[i]['intro']%></td>
    </tr>
    <% } %>
    <tr>
        <td colspan="11" align="left">
            金额合计：<span class="text-danger">&yen;<%=countMoney['total_money']%></span>
        </td>
    </tr>
</script>
<script src="#{$smarty.const.APP}#/View/template/js/content.js?v=1.0.0"></script>
<script type="text/javascript">


    $(document).ready(function () {
        $('.nav-tabs li').each(function (index, val) {
            var tabl_index = index + 1;
            ajax_contract_detail(tabl_index);
        });
    });

    function ajax_contract_detail(tabl_index) {
        if (tabl_index == 1) {
            $.ajax({
                type: "POST",
                url: "#{$smarty.const.ACT}#/erp/PosContractList/pos_contract_list_json/",
                data: {"contract_id": "#{$one.contract_id}#"},
                dataType: "json",
                success: function (returnJsonData) {
                    var tpl = baidu.template;
                    var html = tpl('tab-' + tabl_index + '-Tpl', returnJsonData);
                    $("#tab-" + tabl_index + " tbody").html(html);
                },
                complete: function () {
                },
            });
        } else if (tabl_index == 2) {
            var ajax_url = "#{$smarty.const.ACT}#/erp/FinPayRecord/fin_pay_record_json/";
            $.ajax({
                type: "POST",
                url: ajax_url,
                data: {"contract_id": "#{$one.contract_id}#", "pageSize": "1000"},
                dataType: "json",
                success: function (returnJsonData) {
                    var tpl = baidu.template;
                    var html = tpl('tab-' + tabl_index + '-Tpl', returnJsonData);
                    $("#tab-" + tabl_index + " tbody").html(html);
                },
            });
        } else if (tabl_index == 3) {
            var ajax_url = "#{$smarty.const.ACT}#/erp/FinInvoiceRece/fin_invoice_rece_json/";
            $.ajax({
                type: "POST",
                url: ajax_url,
                data: {"contract_id": "#{$one.contract_id}#", "pageSize": "1000"},
                dataType: "json",
                success: function (returnJsonData) {
                    var tpl = baidu.template;
                    var html = tpl('tab-' + tabl_index + '-Tpl', returnJsonData);
                    $("#tab-" + tabl_index + " tbody").html(html);
                },
            });
        }

    }


</script>